import Vue from 'vue';
import Router from 'vue-router';
import Register from '../views/RegisterVd.vue';
import LoginVd from '../views/LoginVd.vue';
import BookList from '../views/BookList.vue';

// 每一个路由对应一个组件

Vue.use(Router);

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/register',
      name: 'Register',
      component: Register
    },
      {
      path: '/login',
      name: 'LoginVd',
      component: LoginVd
    },
      {
  path: '/booklist', // 嵌套路由 公共部分的路由CenterView，主要应用层
  component: () => import('../views/CenterView.vue'), // 公共布局
  // redirect: '/booklist/booklist', // 添加这一行，作用就是实际访问的/booklist；重定向到/booklist/booklist
  children: [
    {
      path: 'booklist', // Booklist 路由 访问的时候 /booklist/booklist
      name: 'Booklist',
      component: BookList
    }
  ]
}
  ]
});